package cn.hdustea.shopNavigation.ui.model

import cn.hdustea.shopNavigation.entity.Child
import cn.hdustea.shopNavigation.entity.Life
import cn.hdustea.shopNavigation.net.MyService
import cn.hdustea.shopNavigation.ui.contract.ChildContract
import cn.hdustea.shopNavigation.ui.contract.LifeContract
import com.hdustea.base.base.BaseModel
import com.hdustea.base.net.BaseCallback
import com.hdustea.base.net.BaseObserver

/**
 * <pre>
 *     author : HuQiang
 *     time   : 2020/09/21
 *     desc   :
 *     version: 1.0
 * </pre>
 */
class ChildModel : BaseModel(), ChildContract.Model {

    override fun getChildList(page: Int, callback: BaseCallback<MutableList<Child>>) {
        changeThread(MyService.childService().getChild(page),
                object : BaseObserver<MutableList<Child>>(callback) {
                    override fun onNext(t: MutableList<Child>) {
                        callback.callback(t)
                    }
                })
    }

    override fun getSearchList(keyword: String, callback: BaseCallback<MutableList<Child>>) {
        changeThread(MyService.childService().getSearch(keyword),
                object : BaseObserver<MutableList<Child>>(callback) {
                    override fun onNext(t: MutableList<Child>) {
                        callback.callback(t)
                    }
                })
    }

}